package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.BuyCarBean;
import com.project.bean.ProductBean;
import com.project.bean.UserBean;
import com.project.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.util.Map;

@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private IProductService service;
    @RequestMapping("onblur")
    public ProductBean onblur(int proId){
        ProductBean product =  service.findById(proId);
        return product;
    }
    @RequestMapping("findAll")
    public PageInfo<ProductBean> findAll(int pageNO, String name, String type,
                                         int startNum,int endNum){
        return service.findByItem(pageNO, name, type, startNum, endNum);
    }


    @RequestMapping("updatePrice")
    public String updatePrice(int proId,int price){
        service.updatePrice(proId, price);
        return "ok";
    }
    @RequestMapping("findById")
    public ProductBean findById(int proId){
        return service.findById(proId);
    }
    @RequestMapping("updateNum")
    public String updateNum(int proId,int number){
        service.updateNum(proId, number);
        return "ok";
    }
}
